﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
///CategoryDescriptionDao 的摘要说明
/// </summary>
public class CategoryDao : ICategoryDao
{
	public CategoryDao()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    #region ICategoryDao 成员

    public void UpdateCategoryDescription(Category category)
    {
        SqlOpHelper.Execute("niyi", new Object[] { "categoryId", "categoryDescription" }, 
            new Object[] { category.CategoryId, category.CategoryDescription },
            "Update Category Set CategoryDescription = @categoryDescription where CategoryId = @categoryId");
    }

    public Category GetCategoryByName(string categoryName)
    {
        DataSet ds = SqlOpHelper.Query("niyi", new Object[] { "categoryName" }, new Object[] { categoryName }, "select * from Category where CategoryName=@categoryName");
        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            return Category.ConvertToCategory(ds.Tables[0].Rows[0]);
        else
            return null;
    }

    public IList<Category> GetCategoryList()
    {
        DataSet ds = SqlOpHelper.Query("niyi", new Object[] {}, new Object[] {},"select * from Category");
        if (ds.Tables.Count > 0)
            return Category.ConvertToCategoryList(ds.Tables[0]);
        else
            return null;
    }

    #endregion
}
